# 1.导包（快捷键：alt + enter）
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
# 2.打开浏览器（创建浏览器驱动对象）
# path = r"E:\Python\chromedriver.exe" # 定义驱动路径
# ser = Service(executable_path=path) # 实例化Chrome浏览器服务驱动
driver = webdriver.Chrome(executable_path=r"E:\Python\chromedriver.exe") # 打开Chrome浏览器
# 3.输入网址
driver.get("http://121.43.169.97:8848/pageA.html")
# 4.页面操作
# 属性定位：建议选择具有唯一性的属性
driver.find_element(By.XPATH,"//input[@name='userA']").send_keys("admin")
driver.find_element(By.XPATH,"//*[@id='passwordA']").send_keys("123456")
# 属性和逻辑结合
driver.find_element(By.XPATH,"//*[@type='button' and @value='prompt']").click()
# 5.等待2秒
time.sleep(2)
# 6.退出浏览器
driver.quit()